home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 27 / CDROM27.iso / share / progra / mai / Common Dialog, Save File - called with API < prev    next >
Encoding:
Text File  |  1997-07-14  |  1.6 KB  |  50 lines

  1. 'Description: Calls the "Save File Dialog" without need for an OCX
  2. 'Be careful when dealing with this and the "Open File Dialog", the
  3. 'Type and examples are the same. It can be confusing...
  4.  
  5. 'Private Type OPENFILENAME
  6. '    lStructSize As Long
  7. '    hwndOwner As Long
  8. '    hInstance As Long
  9. '    lpstrFilter As String
  10. '    lpstrCustomFilter As String
  11. '    nMaxCustFilter As Long
  12. '    nFilterIndex As Long
  13. '    lpstrFile As String
  14. '    nMaxFile As Long
  15. '    lpstrFileTitle As String
  16. '    nMaxFileTitle As Long
  17. '    lpstrInitialDir As String
  18. '    lpstrTitle As String
  19. '    flags As Long
  20. '    nFileOffset As Integer
  21. '    nFileExtension As Integer
  22. '    lpstrDefExt As String
  23. '    lCustData As Long
  24. '    lpfnHook As Long
  25. '    lpTemplateName As String
  26. 'End Type
  27.  
  28. 'Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
  29.  
  30.     Dim ofn As OPENFILENAME
  31.     ofn.lStructSize = Len(ofn)
  32.     ofn.hwndOwner = Form1.hWnd
  33.     ofn.hInstance = App.hInstance
  34.     ofn.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "Rich Text Files (*.rtf)" + Chr$(0) + "*.rtf" + Chr$(0)
  35.         ofn.lpstrFile = Space$(254)
  36.         ofn.nMaxFile = 255
  37.         ofn.lpstrFileTitle = Space$(254)
  38.         ofn.nMaxFileTitle = 255
  39.         ofn.lpstrInitialDir = curdir
  40.         ofn.lpstrTitle = "Our File Save Title"
  41.         ofn.flags = 0
  42.         Dim a
  43.         a = GetOpenFileName(ofn)
  44.  
  45.         If (a) Then
  46.                 MsgBox "File to Save: " + Trim$(ofn.lpstrFile)
  47.         Else
  48.                 MsgBox "Cancel was pressed"
  49.         End If
  50.